package cn.gok.springbootdemo1.controller;


import cn.gok.springbootdemo1.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private User user;
    

    @RequestMapping("/login")
    public String login(@RequestBody User user){
        user.setUsername("zhangsan");
        user.setPassword("123");

        if (user.getUsername().equals(this.user.getUsername())
                &&user.getPassword().equals(this.user.getPassword())){
            return "登录成功";
        }
        return "登录失败";
    }

    @RequestMapping("/regist")
    public String regist(@RequestBody User user){
        if (user.getUsername().equals(this.user.getUsername())
                &&user.getPassword().equals(this.user.getPassword())){
            return "注册成功";
        }
        return "注册失败";
    }

}
